﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jxym.DBUtility;
using Jxym.wlkc2011.Module.CMS.MODEL;
using Jxym.wlkc2011.Module.CMS.Public;
using System.Web.UI.HtmlControls;

namespace Jxym.wlkc2011
{
    public partial class menu : System.Web.UI.UserControl
    {
        private string siteName = "0";
        public string SiteName { get { return siteName; } set { siteName = value; } }
        private MsSqlDal<Cms_ContentClass> ccClass = new MsSqlDal<Cms_ContentClass>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["siteName"] != null)
            {
                siteName = Request.Params["siteName"];

                if (!IsPostBack)
                {
                    string where = string.Format("ParentID=0 AND siteName='{0}' AND Title<>'{1}'", siteName, "隐藏");
                    Repeater1.DataSource = ccClass.GetList(where, null, "Sort", 0);
                    Repeater1.DataBind();
                }
            }
        }

        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HiddenField HiddenField1 = e.Item.FindControl("HiddenField1") as HiddenField;
            Repeater Repeater2 = e.Item.FindControl("Repeater2") as Repeater;

            if (HiddenField1 != null && Repeater2 != null)
            {
                string where = string.Format("ParentID={1} AND siteName='{0}'", siteName, HiddenField1.Value);

                Repeater2.DataSource = ccClass.GetList(where, null, "Sort", 0);
                Repeater2.DataBind();
            }
        }
    }
}